home *** CD-ROM | disk | FTP | other *** search
- /*
- Functions for getting and setting the name maintained by the Chooser
- Desk Accessory. Getting this name relies on the undocumented feature
- that the name is stored in a 'STR ' resource in the System file.
-
- Revision History:
-
- 91/04/23 AIH
- - When setting the chooser name there's no need to set the resource file
- to the system resource file
-
- 91/04/21 AIH
- - Shortened string parameters to their maximum length of 31 characters
-
- 91/03/11 AIH
- - Removed unused functions for modifying the 'DITL' resource of the
- Chooser, since they don't work with new (v7.0) system software
-
- 91/01/21 AIH
- - Added brief comment describing purpose of this file
-
- 91/01/05 Ari Halberstadt
- - Inserted this standard header in all files */
-
- #include <string.h>
- #include "MemoryLib.h"
- #include "StringLib.h"
- #include "ResourceLib.h"
- #include "ChooserLib.h"
-
- #define CHOOSER_NAME_LEN (32) /* maximum length of a chooser name */
- #define STR_CHOOSER_NAME_ID (-16096) /* system resource containing chooser name */
-
- /* get the current chooser name */
- OSErr ChooserNameGet(CStr31 name)
- {
- BEGIN
- return(ResString31(STR_CHOOSER_NAME_ID, name));
- END
- }
-
- /* set the current chooser name */
- OSErr ChooserNameSet(CStr31 the_name)
- {
- BEGIN
- short oldref; /* original resource file */
- char name[CHOOSER_NAME_LEN]; /* truncated name */
- Handle rsrc; /* the chooser name resource */
- OSErr err = noErr;
-
- require(StrValid(name, sizeof(CStr31)));
-
- /* truncate name to the maximum length */
- strncpy(name, the_name, CHOOSER_NAME_LEN-1);
- name[CHOOSER_NAME_LEN-1] = 0;
-
- /* use system resource file */
- oldref = CurResFile();
- UseResFile(0);
-
- /* get handle to chooser name resource */
- err = ResGet(&rsrc, 'STR ', STR_CHOOSER_NAME_ID);
- if (! err) {
-
- /* un-protect the chooser name resource */
- err = ResAttributeSet(rsrc, resProtected, false);
- if (! err) {
-
- /* set the chooser name resource */
- err = ResStringSet(STR_CHOOSER_NAME_ID, name);
- }
- }
-
- /* restore resource file */
- UseResFile(oldref);
-
- return(err);
- END
- }
-